#pragma once

#include "VerifyDialog.h"
#include "violate_data.h"
#include "windows_socket.h"


class CAlarmGuiDlg : public CDialog
{
public:
	CAlarmGuiDlg(CWnd* pParent = NULL);

	enum { IDD = IDD_ALARMGUI_DIALOG };
	enum { VERIFY_DIALOG_MAX = 20 };
	enum { ALARM_TIME_ID = 11 };
	enum { VIOID_MAX = 100000 };

	BOOL GetVioIndex(int *p_index);
	BOOL IsCreateDlg(int *p_index);

protected:
	HICON         m_hIcon;
	CVerifyDialog m_verifyDialog[VERIFY_DIALOG_MAX];
	BOOL          m_alarmFlag[VERIFY_DIALOG_MAX];
	char          m_vioPicPath[VERIFY_DIALOG_MAX][256];
	int           m_vioId[VERIFY_DIALOG_MAX];
	t_VioData     m_vioDataArray[VERIFY_DIALOG_MAX];
	t_VioData     m_vioData;
	BOOL          m_analyzeFlag;
	int           m_nowVioId;
	HANDLE        m_picDirHandle;
	HANDLE        m_photoSocketHandle;
	HANDLE        m_dirEvtHandle;
	HANDLE        m_sockEvtHandle;
	CRITICAL_SECTION m_anaFlagLock;

	void ModExtResult(char *p_result);
	void PrintVioInfo();
	int GetNowTime();
	bool TraversalFolder(const char *p_eventDir);
	int GetMsgType(const int vioType);
	void ForwardAnalyzer();
	void GetTimeStr(const char *p_intime, char *p_outtime);
	bool TransVioHead(const SOCKET connfd, t_VioHead *p_vio_head);
	bool TransHeartBeat(const SOCKET connfd, t_HeartBeat *p_heart_beat);
	bool TransReserved(const int connfd, t_VioData *p_vio_data, char *p_local_path, const int local_path_size);
	static void AnalyzerSocketFunc(void *p_para);
	static void PhotoSocketFunc(void *p_para);
	static void CheckPicDirFunc(void *p_para); 
	virtual BOOL OnInitDialog();
	virtual void DoDataExchange(CDataExchange* pDX);
	virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
	afx_msg void OnClose();
	afx_msg void OnTimer(UINT_PTR nIDEvent);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	afx_msg LRESULT OnCloseVerifyDialogMsg(WPARAM,LPARAM);
	afx_msg LRESULT OnShowTask(WPARAM wParam,LPARAM lParam);
	DECLARE_MESSAGE_MAP()
};

